********************************************************************
*                                                                  *
* The Determinants of Environmental Migrants’ Conflict Perception  *
*                                                                  *
* Vally Koubi, Tobias Böhmelt, Gabriele Spilker, and Lena Schaffer *
*                                                                  *
* This Version: July 3, 2017                                       *
*                                                                  *
* Address Correspondence to: tbohmelt@essex.ac.uk                  *
*                                                                  *
********************************************************************

use "IO Migration and Conflict.dta", clear

**************
* Tables 2-6 *
**************

foreach var of varlist conflict_perception socpsy econ enviro polconflict {
melogit `var' sudden_events gradual_events female age hh_migrated educ_no educ_prim educ_sec || country: || cluster_sub_country:
melogit `var' sudden_events gradual_events female age hh_migrated h_poor h_rich || country: || cluster_sub_country:
melogit `var' sudden_events gradual_events female age hh_migrated econ_reason || country: || cluster_sub_country:
melogit `var' sudden_events gradual_events female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof || country: || cluster_sub_country:
}

************
* Figure 2 *
************

use "Substantive Effects_Final.dta", clear

twoway (scatter yaxis estimate, mcolor(black) msymbol(smcircle)) (rcap lb ub yaxis, horizontal msize(zero)), ylabel(0(0.5)10.5, labels) legend(off) scheme(lean1) aspectratio(1)

****************************************
* Robustness Checks - Appendix Table 1 *
****************************************

use "IO Migration and Conflict.dta", clear

melogit conflict_perception i.sudden_events##i.excluded i.gradual_events##i.excluded female age hh_migrated educ_no educ_prim educ_sec || country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##i.excluded i.gradual_events##i.excluded female age hh_migrated h_poor h_rich || country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##i.excluded i.gradual_events##i.excluded female age hh_migrated econ_reason || country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##i.excluded i.gradual_events##i.excluded female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof || country: || cluster_sub_country:

****************************************
* Robustness Checks - Appendix Table 2 *
****************************************

preserve

sum exclpop
keep if exclpop<r(mean)

melogit conflict_perception sudden_events gradual_events female age hh_migrated educ_no educ_prim educ_sec || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated h_poor h_rich || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated econ_reason || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof || country: || cluster_sub_country:

restore

****************************************
* Robustness Checks - Appendix Table 3 *
****************************************

preserve

sum years_lived_here, detail
xtile tercile = years_lived_here, nq(10)
keep if tercile==1

melogit conflict_perception sudden_events gradual_events female age hh_migrated educ_no educ_prim educ_sec || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated h_poor h_rich || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated econ_reason || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof || country: || cluster_sub_country:

restore 

****************************************
* Robustness Checks - Appendix Table 4 *
****************************************

use "Migrants and Non-Migrants.dta", clear

heckprob conflict_perception=sudden_events gradual_events educ_sec, sel(migrant=sudden_events gradual_events female age hh_migrated educ_no educ_prim educ_sec) cluster(country)
heckprob conflict_perception=sudden_events gradual_events h_poor, sel(migrant=sudden_events gradual_events female age hh_migrated hh_migrated h_poor h_rich) cluster(country)
heckprob conflict_perception=sudden_events gradual_events, sel(migrant=sudden_events gradual_events female age hh_migrated econ_reason) cluster(country)
heckprob conflict_perception=sudden_events gradual_events, sel(migrant=sudden_events gradual_events female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof) cluster(country)

****************************************
* Robustness Checks - Appendix Table 5 *
****************************************

use "IO Migration and Conflict.dta", clear

melogit conflict_perception sudden_events gradual_events || country: || cluster_sub_country:

****************************************
* Robustness Checks - Appendix Table 6 *
****************************************

melogit conflict_perception sudden_events gradual_events female age hh_migrated educ_no educ_prim educ_sec polity GDPpc || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated h_poor h_rich polity GDPpc || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated econ_reason polity GDPpc || country: || cluster_sub_country:
melogit conflict_perception sudden_events gradual_events female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof polity GDPpc || country: || cluster_sub_country:

****************************************
* Robustness Checks - Appendix Table 7 *
****************************************

melogit conflict_perception i.sudden_events##c.polity i.gradual_events##c.polity female age hh_migrated educ_no educ_prim educ_sec || country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##c.polity i.gradual_events##c.polity female age hh_migrated h_poor h_rich || country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##c.polity i.gradual_events##c.polity female age hh_migrated econ_reason|| country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##c.polity i.gradual_events##c.polity female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof || country: || cluster_sub_country:

****************************************
* Robustness Checks - Appendix Table 8 *
****************************************

melogit conflict_perception i.sudden_events##c.GDPpc i.gradual_events##c.GDPpc female age hh_migrated educ_no educ_prim educ_sec || country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##c.GDPpc i.gradual_events##c.GDPpc female age hh_migrated h_poor h_rich || country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##c.GDPpc i.gradual_events##c.GDPpc female age hh_migrated econ_reason|| country: || cluster_sub_country:
melogit conflict_perception i.sudden_events##c.GDPpc i.gradual_events##c.GDPpc female age hh_migrated civilservant oc_business_sales craft_trade_workers elementary_occupation other_prof || country: || cluster_sub_country:

****************************************
* Robustness Checks - Appendix Table 9 *
****************************************

logit conflict_perception sudden_events gradual_events female age hh_migrated educ_no educ_prim educ_sec i.country
